<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Home</title>
</head>
<script type="text/javascript" src="/webjars/jquery/1.11.3/jquery.js"></script>
<script type="text/javascript" src="/webjars/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/webjars/github-com-sentsin-layer/3.0.3/src/layer.js"></script>
<link rel="stylesheet" type="text/css" href="/webjars/bootstrap/3.3.7/css/bootstrap.css">
<body style="background-color: #f5f5f5;">
<#include "hearder.ftl"/>

<div class="form-group-in" style="padding-left: 35%;padding-right: 35%;padding-top: 5%;">
    <label style="font-size: 50px;">Groovy Tool</label>
    <form role="form">
        <table>
            <td><label for="emailInputLabel" style="font-size: 18px;"><label style="color: red">*</label>邮箱：</label></td>
            <td><input type="text" id="emailToken" required class="form-control"
                                           placeholder="邮箱">
            </td>
            <td style="width: 20px"></td>
            <td colspan="2" align="center">
                <button value="授权" type="button" onclick="loginSubmit()" class="btn btn-primary">授权</button>
            </td>
        </table>
    </form>
</div>
</body>
<script>

    function isNull(val) {
        if (val == null || val == undefined || val == "") {
            return true;
        }
        return false
    }

    function loginSubmit() {
        var url = "/api/loginToken";
        var email = $("#emailToken").val().trim();

        if(isNull(email)){
            layer.msg("需要输入邮箱授权！");
            return;
        }
        var data = {"email": email};
        $.post(url, data, function (result) {
            console.log(result)
            layer.msg(result.message);
            emailInputLabel.html(result.message);
            //设置浏览器cookie
        });
    }

</script>
<style>
    label {
        margin-bottom: 0px;
    }
</style>
</html>